package com.bytenebula.asteroid.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.bytenebula.asteroid.entity.BnAccount;
import com.bytenebula.asteroid.mapper.BnAccountMapper;
import com.bytenebula.asteroid.service.BnAccountService;
import org.springframework.stereotype.Service;

/**
 *  服务层实现。
 *
 * @author patrick
 * @since 2024-10-30
 */
@Service
public class BnAccountServiceImpl extends ServiceImpl<BnAccountMapper, BnAccount> implements BnAccountService {
    /**
     * 根据用户名查询帐户对象
     * @param userName 用户名
     * @return 如果用户名对应的用户存在则返回BnUser对象，否则返回NULL
     */
    public BnAccount getOneByUserName(String userName) {
        QueryWrapper querier = QueryWrapper.create().eq("user_name", userName);
        return mapper.selectOneWithRelationsByQuery(querier);
    }
}
